from binance.client import Client
import json

# 初始化客户端
client = Client(api_key='W1Z5h7RydJ8CNI40azIXOJKVudRLfawy3k8jEdbh0sfU74yHQzVr5a78IU2E2lRV', api_secret='ZMvkc39AOccvuxLnREzFPx7UZY11grocC08qO8R1lSe7L5yGyyZyq4WlwxF0u0gr')

# 获取市场信息
exchange_info = client.get_exchange_info()

# 提取市场中每个交易对的最小交易量
min_trade_volumes = {}

for symbol_info in exchange_info['symbols']:
    if symbol_info['status'] != 'TRADING':
        print(symbol_info)
        continue
    symbol = symbol_info['symbol']
    base_asset = symbol_info['baseAsset']
    quote_asset = symbol_info['quoteAsset']
    min_qty = None
    min_price = None
    
    for filter_ in symbol_info['filters']:
        if filter_['filterType'] == 'LOT_SIZE':
            min_qty = float(filter_['minQty'])  # baseAsset 最小交易量
        elif filter_['filterType'] == 'PRICE_FILTER':
            min_price = float(filter_['minPrice'])  # quoteAsset 最小交易量
    
    min_trade_volumes[symbol] = {
        'baseAsset': base_asset,
        'minBaseQty': min_qty,
        'quoteAsset': quote_asset,
        'minQuoteQty': min_price
    }

# 将结果保存为 JSON 文件
with open('min_trade_volumes.json', 'w') as f:
    json.dump(min_trade_volumes, f, indent=4)

print("Min trade volumes saved to min_trade_volumes.json")